<?php
	class mhangxe extends connect_db{
		protected $_hang;
		protected $_id;
		
		public function __construct(){
			$this->connect();
		}
		public function sethang($hang){
			$this->_hang = $hang;
		}
		public function gethang(){
			return $this->_hang;
		}
		public function setid($id){
			$this->_id = $id;
		}
		public function getid(){
			return $this->_id;
		}
		public function hangxe(){
			$sql = "select * from hangsx order by hang_id DESC";
			$this->query($sql);
			if($this->num_rows() == 0){
				return false;
			}else{
				while($row = $this->fetch()){
					$data[] = $row;
				}
				return $data;
			}
		}
		public function kiemtra(){
			$sql = "select * from hangsx where tenhang = '".$this->gethang()."'";
			$this->query($sql);
			if($this->num_rows() != 0){
				return false;
			}else{
				return true;
			}
		}
		public function insert(){
			$sql = "insert into hangsx(tenhang) values('".$this->gethang()."')";
			$this->query($sql);
		}
		public function del(){
			$sql = "delete from hangsx where hang_id='".$this->getid()."'";
			$this->query($sql);
		}
		public function show($id){
			$sql = "select * from hangsx where hang_id = '$id'";
			$this->query($sql);
			return $this->fetch();
		}
		public function edit(){
			$sql="update hangsx set tenhang='".$this->gethang()."' where hang_id='".$this->getid()."'";
			$this->query($sql);
		}
	}
?>